package log

import (
	"d-serv-go/server/core/config"
	"github.com/sirupsen/logrus"
)

var log = logrus.New()

func InitLog() {

	level := logrus.DebugLevel
	log.SetLevel(logrus.ErrorLevel)

	switch config.Instance.LogLevel {
	case "debug":
		level = logrus.DebugLevel
	case "info":
		level = logrus.InfoLevel
	case "error":
		level = logrus.ErrorLevel
	case "fatal":
		level = logrus.FatalLevel
	default:
		level = logrus.DebugLevel
	}

	log.Formatter = &logrus.JSONFormatter{}
	log.SetLevel(level)
}

func Info(v ...interface{}) {
	log.Info(v...)
}

func Infof(fmt string, v ...interface{}) {
	log.Infof(fmt, v...)
}

func Debug(v ...interface{}) {
	log.Debug(v...)
}
func Fatal(v ...interface{}) {
	log.Fatal(v)
}

func Error(v ...interface{}) {
	log.Error(v...)
}
